﻿using UnityEngine;
using System.Collections.Generic;
using Dict.DataModel;

namespace UI
{
    public class UITaskData
    {
        public string task_id;
        public string task_id_number;
        public string task_mission_id;
        public string task_hero_id;
        public float task_rotate_speed;
        public float task_rest_time;
        public Vector3 task_born;
        public float task_face_to;
        public float task_wander_distance;
        public float task_wander_speed;
        public float task_pursue_distance;
        public float task_pursue_speed;
        public float task_view_distance;
        public string task_dead_particle;
        public string task_born_particle;
        public int task_born_type;
        public string task_drop_odds;
        //public int task_gain_exp;
        //public int task_gain_coin;
        public int task_seq;
        public UITaskData( TableCopyTask task )
        {
            this.task_id = task.TaskId;
            this.task_mission_id = task.MissionId;
            this.task_pursue_distance = (float)task.PursueR;
            this.task_pursue_speed = (float)task.PursueSpeed;
            this.task_rest_time = (float)task.RestTime;
            this.task_rotate_speed = (float)task.RotateSpeed;
            this.task_view_distance = (float)task.ViewR;
            this.task_wander_distance = (float)task.WanderR;
            this.task_wander_speed = (float)task.WanderSpeed;
            this.task_born = new Vector3( (float)task.BornX, 0, (float)task.BornZ );
            this.task_born_particle = task.BornParticleId;
            this.task_born_type = task.BornType;
            this.task_dead_particle = task.DeadParticleId;
            this.task_drop_odds = task.DropOdds;
            this.task_face_to = (float)task.BornAngle;
            //this.task_gain_coin = task.GainCoin;
            //this.task_gain_exp = task.GainExp;
            this.task_hero_id = task.HeroId;

            if( this.task_id.Contains( "_" ) )
            {
                string[] s= task_id.Split( new char[1] { '_' }, System.StringSplitOptions.RemoveEmptyEntries );
                this.task_id_number = s[s.Length-1];
            }
            else
            {
                this.task_id_number = this.task_id;
            }
        }

        public void Copy( UITaskData data )
        {
            this.task_id = data.task_id;
            this.task_mission_id = data.task_mission_id;
            this.task_pursue_distance =  data.task_pursue_distance;
            this.task_pursue_speed = data.task_pursue_speed;
            this.task_rest_time = data.task_rest_time;
            this.task_rotate_speed = data.task_rotate_speed;
            this.task_view_distance = data.task_view_distance;
            this.task_wander_distance = data.task_wander_distance;
            this.task_wander_speed = data.task_wander_speed;
            this.task_born = new Vector3( data.task_born.x, 0, data.task_born.z );
            this.task_born_particle = data.task_born_particle;
            this.task_born_type = data.task_born_type;
            this.task_dead_particle = data.task_dead_particle;
            this.task_drop_odds = data.task_drop_odds;
            this.task_face_to = data.task_face_to;
            //this.task_gain_coin = data.task_gain_coin;
            //this.task_gain_exp = data.task_gain_exp;
            this.task_hero_id = data.task_hero_id;
            this.task_id_number = data.task_id_number;
        }
    }

}